-- town3 - "Sallar"

function autoexec()
  set_progress(P_Payed, 0);
  set_progress(P_Payed2, 0);
  set_progress(P_Robbed, 0);


         return
end

function refresh()
  return
end

function postexec()
end

function zone_handler(zn)
    if (zn == 1) then
    change_map("myland",123,58,123,58);

  elseif (zn == 2) then
    door_in(96,9,91,2,101,11);

  elseif (zn == 3) then
    door_out(16,9);

  elseif (zn == 4) then
    door_in(96,24,91,17,101,26);

  elseif (zn == 5) then
    door_out(7,15);  

elseif (zn == 6) then
    

  elseif (zn == 7) then
    door_in(112,25,107,18,117,28);

  elseif (zn == 8) then
    door_out(33,7);

  elseif (zn == 9) then
    
  elseif (zn == 10) then
    door_in(129,41,123,34,135,43);

  elseif (zn == 11) then
    door_out(60,9);
      
  elseif (zn == 12) then
    door_in(111,9,105,2,117,11);

  elseif (zn == 13) then
    door_out(5,28); 
        
  elseif (zn == 14) then
        
  elseif (zn == 15) then
    touch_fire(get_pidx(0));

  elseif (zn == 17) then
    shop(11);

  elseif (zn == 18) then  
   
    
  elseif (zn == 19) then  
      if (get_progress(P_Payed2) == 1) then
      view_range(1,135,58,148,69);
      warp (147,67,8);
      else
      bubble(7,"Please pay before you go to a room.");
         end

   

  elseif (zn == 20) then
    view_range(1,105,2,117,11);
    warp (116,9,8);

  elseif   (zn == 21) then
    thought(HERO1,"My room is on this floor not the next.");

  elseif   (zn == 22) then
      thought(HERO1,"There is a scroll that reads:",
                              "Please sign our guest book and",
                              "feel free to write some comments.");
      if (prompt(255,2,0,"hmm"," This place has good service.","  I rather sleep at the Flotsam.","") == 0) then
      end

  elseif (zn == 23) then  
      if (prompt(255,2,0,"Do you want to sleep?","  yes","  no","") == 0) then
         for a=0,get_numchrs()-1,1 do
        set_party_hp(a,get_party_mhp(a));
        set_party_mp(a,get_party_mmp(a));
        end
      inn("House",0,0);
    end
  
  elseif (zn == 24) then
 --   if (get_progress(P_Robbed) == 0) then
      bubble(0,"Welcome to the Flotsam and Jetsam.");
      bubble(0,"BELCH!!!");
      bubble(0,"Wha' d'ya want?");
      if (prompt(255,2,0,"hmm"," A room","  Nothing","") == 0) then
      bubble(0,"We dont have rooms, but your quarters are upstairs.");

       if (get_gp() >= 5) then
            set_gp(get_gp()-5);
            msg("The inn keeper takes 5 gp from you!",255,0);
            set_progress(P_Payed, 1);

        else
          bubble(0,"You dont have 5gp?");
          bubble(0,"Slasher chuck 'em out.");      
          view_range(1,0,0,200,200);
          warp(33,8,8);
         

  end
        
    
    else
    bubble(0,"Well scram then.");
    end

--  else
  --    bubble(HERO1,"I just got ROBBED!!");
    --  bubble(0,"Oh thats just too bad.");
    --  bubble(HERO1,"This is the worst inn I have ever gone to.");
    --  bubble(0,"Slasher chuck 'em out.");
      --    view_range(1,0,0,200,200);
         -- warp(33,8,8);
     
    
        
  elseif (zn == 25) then
    if (get_progress(P_Payed) == 1) then
      change_map("townx3",117,62,117,62);
      else
       bubble(0,"Where da ya think yur going?");
       bubble(0,"Ya hafta pay first.");
       end

  elseif (zn == 26) then
    view_range(1,107,18,117,27);
    warp(116,20,8);
    
  elseif (zn == 28) then
          if (prompt(255,2,0,"Do you want to sleep?","  yes","  no","") == 0) then
         for a=0,get_numchrs()-1,1 do
        set_party_hp(a,get_party_mhp(a));
        set_party_mp(a,get_party_mmp(a));
        end
      inn("House",0,0);
    msg("You awaken and realize...",255,0);
  msg("You've been robbed!",255,0);
  set_progress(P_Robbed, 1);
    set_gp(get_gp()>= 0);
    end
  

  elseif   (zn == 31) then
       bubble(7,"Welcome to the Seabreeze Inn.");
       bubble(7,"What may I do for you?");
       bubble(7,"It costs 106 gp to rent a room.");
       if (prompt(7,2,0,"Lets see.."," A room","  Nothing","") == 0) then
       bubble(7,"Your room is upstairs.");

       if (get_gp() >=106) then
            set_gp(get_gp()-106);
            msg("You pay the inn keeper.",255,0);
            set_progress(P_Payed2, 1);

        else
          bubble(7,"Sorry you don't have enough gold.");
          end
        end
   elseif   (zn == 32) then
  bubble(10,"Dont go up there.");

  elseif   (zn == 33) then
  Thought(HERO1,"Hmm... Its locked",
                  "It must not be my room");
 
  elseif   (zn == 34) then
    bubble(HERO1,"THATS A BIG HOLE!!");
    end  
    
function entity_handler(en)
  if (en == 0) then
      
  elseif (en == 1) then 
      bubble(1,"What doth thou wantest?");                     
   if (prompt(1,2,0, "What doth thou wantest?", "A drink", "Nothing","") == 0) then
   bubble(1,"Here you go.");
    thought(HERO1,"You remove the rusty top off the",
                            "drink with your handy pocket knife.");                   
    thought(HERO1,"You then chug the filthy sludge down.");
    bubble(HERO1,"Urgh... That was disgusting!");
    bubble(HERO1,"I didn't think being a hero was going to be so bad.");
    bubble(0,"Stop badmouthing my inn!!");
    bubble(HERO1,"Your hovel you mean?");
    bubble(9,"I will take you out.");
    bubble(HERO1,"What a pack of fools!!");
    else
        bubble(1,"Thats ok, I want whats best for you.");                     
     end                       
                            

  elseif (en == 2) then
    bubble(2,"Yeaaahhh");

   elseif (en == 3) then
    bubble(3,"Tweet tweet, I'm a bird");

   elseif (en == 4) then
    bubble(4,"Ahhhh stranger run!!");

   elseif (en == 5) then
    bubble(5,"My mother forbids me to go to the Flotsam.");
    
   elseif (en == 8) then
    bubble(8,"Hi, I'm a sailor.");

   elseif (en == 9) then
    bubble(9,"I'm the Slasher.");

   elseif (en == 10) then
   if (get_progress(P_Deal) == 0) then
   if (get_treasure(1) == 1) then
      if (prompt(10,2,0,"Did you see my sister in Elerta?"," yes","  no") == 0) then    
      bubble(10,"Since I'm a sailor I might know something that you want.");
      bubble(HERO1,"Here's the mesra feather I found.");
      bubble(10,"Interesting... The warriors of that land, which we never speak of,",
      "just south of here wear those feathers in war.");
      bubble(HERO1,"Well How can I get there?");
      bubble(10,"You can charter a ship for a small fund of 9000 gp.");
      set_progress(P_Deal, 1);
        else
        bubble(10,"I have no idea who you are.");
         bubble(10,"Bye.");
       end
   else
   bubble(10,"I have no idea who you are.");
         bubble(10,"Bye.");    
  end
  else
   bubble(10,"Do you want to charter a ship?");
    bubble(10,"A word of warning to you: There is no turning back after this point.");
   if (prompt(10,2,0,"hmm"," yes","  no","") == 0) then
        if (get_gp() >= 9000) then
            set_gp(get_gp()-9000);
            msg("You hand over the gold.",255,0);
         bubble(10,"Glad to be in business with you.");
         bubble(10,"Lets set off now.");
     
         change_map("boat",18,4,18,4);
       else
           bubble(10,"Come back when you have the gold. Boats aren't kept sailin' with just love.");
   end
          else
             bubble(10,"I will be here when you need me.");
              end
                              
  end
   end
                end                                   
               end               